<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>人工确认</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layuimini-container">
        <blockquote class="layui-elem-quote layui-text">
            注意事项：1.人工确认
        </blockquote>
    <div class="layuimini-main">
        <form class="layui-form layui-form-pane" action="">
            <input type="hidden" name="pipeline_id" readonly="true" value="" class="layui-input" disabled>
            <div class="layui-form-item">
                <label class="layui-form-label required">审核用户</label>
                <div class="layui-inline">
                  <div class="layui-input-inline" style="width:300px">
                      <input type="text" name="review_users" lay-verify="required" lay-reqtext="不能为空" placeholder="" value="" class="layui-input">
                  </div>
                  <div class="layui-form-mid" style="color: red;">填写审核用户,多个逗号隔开</div>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">备注</label>
                <div class="layui-input-block" style="width:300px">
                    <input type="text" name="remarks" placeholder="不超过50字符" value="" class="layui-input">
                </div>
            </div> 

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
                </div>
            </div>
        </form>
    </div>
</div>
<script src="/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;

		    form.verify({
    			nickname: function(value){
    			  if(value.length < 4){
    				return '至少5个字符且不能有特殊字符';
    			  }
    			}
    			,pass: [/(.+){8,20}$/, '密码必须8到20位']
    			,repass: function(value){
    				if($('#pass').val()!=$('#repass').val()){
    					return '两次密码不一致';
    				}
    			}
		    });	 

        //监听提交
        form.on('submit(saveBtn)', function (data) {
                data.field.socks_user = data.field.socks_user.replace(/^\s*|\s*$/g,""); //替换空格
                data.field.nickname = data.field.nickname.replace(/^\s*|\s*$/g,"");
                data.field.user_ip = data.field.user_ip.replace(/^\s*|\s*$/g,"");
                data.field.remarks = data.field.remarks.replace(/^\s*|\s*$/g,"");
					    //console.log(data.field);
			        layer.confirm('确定添加?', {icon: 3, title:'提示',yes: function(index){
                     var index2 = layer.load(0, {shade: false});
                     layer.msg('此处需运行3-5s左右');
                     $.ajax({
                       url: "/socks/v1/AddUser",
                       type: "post",
                       data: JSON.stringify(data.field),
                       dataType: "json",
                       success: function (resp) {
                                layer.close(index2);
                                 if(resp.code == 0){
                                    layer.msg('添加成功', {icon: 1});
									                  window.location.reload();
                                 }else{
                                    layer.msg(resp.msg,{icon:2});
                                 }
                        }
                      });		  	  
                  },
                  cancel: function(index, layero){ 
                    layer.close(index);
                    layer.close(index2);
		                console.log("不操作");
                  } 
                });
              return false;
        });

    });
</script>
</body>
</html>